Skip to content

make width and height public #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 25, 2020

Conversation

FoamyGuy
Copy link
Contributor

Resolves #15 width and height properties exist without leading underscores with this change.

Here is some sample code illustrating the usage of public height property to place a label below the progress bar:

import time
import board
import displayio
from adafruit_progressbar import ProgressBar
from adafruit_display_text import label
import terminalio

# Make the display context
splash = displayio.Group(max_size=10)
board.DISPLAY.show(splash)

# set progress bar width and height relative to board's display
width = board.DISPLAY.width - 40
height = 30

x = board.DISPLAY.width // 2 - width // 2
y = board.DISPLAY.height // 3

# Create a new progress_bar object at (x, y)
progress_bar = ProgressBar(x, y, width, height, 1.0)

# Append progress_bar to the splash group
splash.append(progress_bar)

# make a label
progress_label = label.Label(terminalio.FONT, text="Progress")
progress_label.anchor_point = (0.5, 0.0)

# put it just below the progress bar
progress_label.anchored_position = (board.DISPLAY.width//2, y + progress_bar.height)

splash.append(progress_label)

current_progress = 0.0
while True:
   pass # nothing needed for this example

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll want to make them properties of their own so that setting them causes a redraw. If you don't want the writable then you'll also need a property with just a getter.

@FoamyGuy
Copy link
Contributor Author

I started working on making them writeable with a redraw but I think this is going to require more substantial changes. ProgressBar extends TileGrid which has the Bitmap assigned it its init(). Bitmaps width and height are read only so we'll have to create a new one. I don't see a way to change the Bitmap on the TileGrid, unless that exists I think we'd need to create a new TileGrid also, which I'm not sure if we can do since we're extending it.

If my assumptions above are true then I think changing ProgressBar to extend Group instead of TileGrid will be the easiest way to allow for redrawing.

For now I've made them into properties without setters. I can look into it further later to get the redraw working.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you!

@tannewt tannewt merged commit 2dde38e into adafruit:master Aug 25, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 26, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 to 2.2.3 from 2.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADS1x15#59 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x to 1.11.4 from 1.11.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADXL34x#25 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_AMG88xx#29 from jepler/pylint-fixes
  > Merge pull request adafruit/Adafruit_CircuitPython_AMG88xx#28 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_APDS9960 to 2.2.2 from 2.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_APDS9960#27 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_BD3491FS to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_BD3491FS#6 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_BluefruitSPI to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_BluefruitSPI#18 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_BMP3XX to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_BMP3XX#9 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_CAP1188 to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_CAP1188#18 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_CharLCD to 3.3.3 from 3.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_CharLCD#49 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_DPS310 to 1.1.5 from 1.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_DPS310#7 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_DRV2605 to 1.1.9 from 1.1.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_DRV2605#24 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_DS1307 to 2.1.3 from 2.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_DS1307#19 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_DS3231 to 2.4.1 from 2.4.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DS3231#29 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_DS3502 to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_DS3502#6 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_FXAS21002C to 2.1.3 from 2.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_FXAS21002C#16 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_FXOS8700 to 2.1.3 from 2.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_FXOS8700#19 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_ICM20X to 2.0.3 from 2.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_ICM20X#10 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_INA219 to 3.4.5 from 3.4.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_INA219#25 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_INA260 to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_INA260#12 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS2MDL to 2.1.5 from 2.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS2MDL#10 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH to 5.1.3 from 5.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS3DH#61 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_LPS35HW to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_LPS35HW#6 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM303_Accel to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM303_Accel#9 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM303DLH_Mag to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM303DLH_Mag#9 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS0 to 2.2.3 from 2.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM9DS0#20 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1 to 2.1.3 from 2.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM9DS1#23 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX31855 to 3.2.4 from 3.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_MAX31855#20 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX31865 to 2.2.4 from 2.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_MAX31865#21 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX9744 to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MAX9744#13 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MMA8451 to 1.3.3 from 1.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MMA8451#14 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPL115A2 to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPL115A2#9 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPL3115A2 to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPL3115A2#15 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPR121 to 2.1.3 from 2.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPR121#26 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPRLS to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPRLS#13 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPU6050 to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPU6050#10 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8523 to 1.5.1 from 1.5.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PCF8523#20 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_PCT2075 to 1.1.5 from 1.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_PCT2075#14 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_PN532 to 2.2.1 from 2.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PN532#38 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM9x to 2.0.4 from 2.0.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_RFM9x#49 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_SGP30 to 2.3.1 from 2.3.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_SGP30#30 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_SI4713 to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_SI4713#16 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_SI5351 to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_SI5351#16 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1305 to 1.3.3 from 1.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1305#11 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1306 to 2.8.3 from 2.8.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1306#48 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_TCS34725 to 3.3.3 from 3.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_TCS34725#32 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Thermal_Printer#19 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_TMP006 to 2.1.3 from 2.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_TMP006#12 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_Trellis to 1.3.4 from 1.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Trellis#16 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_TSL2561 to 3.3.3 from 3.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_TSL2561#33 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_TSL2591 to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_TSL2591#18 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_VC0706 to 4.1.3 from 4.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_VC0706#15 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_VCNL4010 to 0.10.3 from 0.10.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_VCNL4010#13 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_VEML6070 to 3.1.3 from 3.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_VEML6070#17 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_VEML6075 to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_VEML6075#13 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L0X to 3.3.3 from 3.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL53L0X#23 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL6180X to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL6180X#15 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_VS1053 to 1.2.3 from 1.2.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_VS1053#13 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_miniesptool to 0.2.4 from 0.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_miniesptool#22 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_MotorKit to 1.5.3 from 1.5.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MotorKit#31 from kattni/i2c-update

Updating https://github.com/adafruit/Adafruit_CircuitPython_ProgressBar to 1.3.3 from 1.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_ProgressBar#16 from FoamyGuy/public_width_and_height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Width and height could be made public
2 participants